package com.heima.utils.common;

import com.heima.model.user.pojos.ApUser;

public class AppThreadLocalUtil {
    //定义ThreadLocal对象
    private final static ThreadLocal<ApUser> APP_USER_THREAD_LOCAL = new ThreadLocal<>();

    // 添加数据到ThreadLocal

    public static void add(ApUser apUser){
        APP_USER_THREAD_LOCAL.set(apUser);
    }

    // 从ThreadLocal中获取数据
    public static ApUser get(){
        return APP_USER_THREAD_LOCAL.get();
    }

    // 清空ThreadLocal中的数据
    public static void remove(){
        APP_USER_THREAD_LOCAL.remove();
    }
}
